part of shop;

class RegisterPage extends StatefulWidget {
  const RegisterPage({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return RegisterPageState();
  }
}

class RegisterPageState extends State<RegisterPage> {
  int stateCode = 0;
  String input = '';
  String log = '';

  void _login() {
    stateCode = input.length % 2;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('登录'),
      ),
      body: Center(
        child: Column(
          children: [
            const SizedBox(
              height: 20,
            ),
            TextField(),
            TextField(),
            //由于注册的逻辑尚未完成，所以这里实在是不知道怎么写（@100）
            const Text(
              '请登录',
              textAlign: TextAlign.center,
              style: TextStyle(
                fontSize: 30,
                color: Colors.white,
              ),
            ),
            const SizedBox(height: 20),
            SizedBox(
              //color: const Color.fromRGBO(111, 106, 245, 1.0),
              //height: 60,
              width: 300,
              child: TextField(
                //cursorHeight: 40,
                cursorWidth: 2,
                //光标宽度
                autofocus: false,
                //controller: ,

                decoration: const InputDecoration(
                    contentPadding: EdgeInsets.all(10),
                    //hoverColor: Colors.white, //没什么效果
                    //focusColor: Colors.yellow,

                    //设置边框用focusedBorder和enabledBorder,直接用border没用
                    focusedBorder: OutlineInputBorder(
                      borderSide: BorderSide(
                        color: Colors.blue,
                        width: 1.5,
                      ),
                      borderRadius: BorderRadius.all(Radius.circular(5)),
                    ),
                    enabledBorder: OutlineInputBorder(
                      borderSide: BorderSide(
                        color: Colors.white,
                        width: 1.5,
                      ),
                      borderRadius: BorderRadius.all(Radius.circular(5)),
                    ),
                    hintText: '请输入',
                    hintStyle: TextStyle(
                      color: Colors.white30,
                    )),
                style: const TextStyle(
                  color: Colors.blue,
                  fontSize: 30,
                  //backgroundColor: Colors.green,
                ),
                textAlign: TextAlign.center,
                onChanged: (String value) {
                  input = value;
                },
              ),
            ),
            const SizedBox(
              height: 20,
            ),
            SizedBox(
              //color: Colors.blue, 无效

              width: 100,
              child: ElevatedButton(
                style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all(Colors.red),
                  padding: MaterialStateProperty.all(const EdgeInsets.all(10)),
                ), //按钮样式，待研究
                child: const Text('确认'),

                onPressed: () {
                  setState(() {
                    _login();
                    log = stateCode == 0 ? '登录失败' : '登录成功';
                  });
                },
              ),
            ),
            Text(
              log,
              style: const TextStyle(
                fontSize: 15.0,
                fontStyle: FontStyle.italic,
                color: Colors.cyanAccent,
              ),
            ),
            Text.rich(
              TextSpan(
                children: [
                  TextSpan(
                    text: "注册",
                    style: const TextStyle(fontSize: 59, color: Colors.yellow),
                    // 设置点击事件
                    recognizer: TapGestureRecognizer()
                      ..onTap = () {
                        Navigator.push(context,
                            MaterialPageRoute(builder: (builder) {
                          return LoginPage();
                        }));
                      },
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
